From 5e61562a328ae5de04f6078308198cec3b12f94a Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Wed, 7 Dec 2005 11:50:55 +0000 Subject: [PATCH] Change configuration handling wrt to the vcpus entry, so that we only see a vcpus entry in the image section when using VMX, only add VMX options at all if the builder is vmx, and issue a warning when overriding the global vcpus setting with the one from the image. This removes the duplicated vcpus entries in the domain's sxpr. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendDomainInfo.py | 16 +++++++++------- tools/python/xen/xm/create.py | 9 +++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 13eae448b7..ce054bb3a0 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -285,16 +285,18 @@ def parseConfig(config): for e in ROUNDTRIPPING_CONFIG_ENTRIES: result[e[0]] = get_cfg(e[0], e[1]) - result['cpu'] = get_cfg('cpu', int) - result['cpus'] = get_cfg('cpus', str) - result['image'] = get_cfg('image') + result['cpu'] = get_cfg('cpu', int) + result['cpus'] = get_cfg('cpus', str) + result['image'] = get_cfg('image') try: if result['image']: - result['vcpus'] = int(sxp.child_value(result['image'], - 'vcpus', 1)) - else: - result['vcpus'] = 1 + v = sxp.child_value(result['image'], 'vcpus') + if v is not None and int(v) != result['vcpus']: + log.warn(('Image VCPUs setting overrides vcpus=%d elsewhere.' + ' Using %s VCPUs for VM %s.') % + (result['vcpus'], v, result['uuid'])) + result['vcpus'] = int(v) except TypeError, exn: raise VmError( 'Invalid configuration setting: vcpus = %s: %s' % diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index 8b8e55517f..622bea9b18 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -424,8 +424,10 @@ def configure_image(vals): config_image.append(['root', cmdline_root]) if vals.extra: config_image.append(['args', vals.extra]) - if vals.vcpus: - config_image.append(['vcpus', vals.vcpus]) + + if vals.builder == 'vmx': + configure_vmx(config_image, vals) + return config_image def configure_disks(config_devs, vals): @@ -573,7 +575,7 @@ def make_config(vals): config.append([n, v]) map(add_conf, ['name', 'memory', 'ssidref', 'maxmem', 'restart', - 'on_poweroff', 'on_reboot', 'on_crash']) + 'on_poweroff', 'on_reboot', 'on_crash', 'vcpus']) if vals.cpu is not None: config.append(['cpu', vals.cpu]) @@ -593,7 +595,6 @@ def make_config(vals): config_image = run_bootloader(vals) else: config_image = configure_image(vals) - configure_vmx(config_image, vals) config.append(['image', config_image]) config_devs = [] -- 2.30.2